
#ifndef __RT_RTMPMGR_API_H__
#define __RT_RTMPMGR_API_H__

#ifdef RT_WIN32
	#if defined (RT_RTMPMGR_DLL)
	  #define RT_RTMPMGR_API __declspec(dllexport)
	#else 
	  #define RT_RTMPMGR_API __declspec(dllimport)
	#endif // RT_RTMPMGR_DLL
#else
	#define RT_RTMPMGR_API 
#endif

#include "RtStdCpp.h"
#include "RtInetAddr.h"
#include "RtReferenceControl.h"

class IRtRtmpMgrSink;
class IRtRtmpSession;
class IRtRtmpSessionSink;

class RT_RTMPMGR_API IRtRtmpMgr
{
public:
	static IRtRtmpMgr* Instance();

	virtual RtResult Initialize(
		IRtRtmpMgrSink* inSink, 
		const CRtInetAddr& inRtmpListenAddr, 
		const CRtInetAddr& inRtmptListenAddr) = 0;

	virtual RtResult ListenAnotherAddr(
		const CRtInetAddr& inListenAddr, 
		BOOL inIsRtmp = TRUE) = 0;

	virtual void Release() = 0;

protected:
	virtual ~IRtRtmpMgr() {}
};

class IRtRtmpMgrSink
{
public:
	virtual void OnNewRtmpSession(IRtRtmpSession* inSession, const CRtString& inScope) = 0;
	
protected:
	virtual ~IRtRtmpMgrSink() {}
};

class IRtRtmpSession : public IRtReferenceControl
{
public:
	virtual void SetSink(IRtRtmpSessionSink* inSink) = 0;
	virtual void NotifyAvData() = 0;
	virtual void Close() = 0;

protected:
	virtual ~IRtRtmpSession() {}
};

typedef enum
{
	RTMP_EVENT_PLAY,
	RTMP_EVENT_CLOSESTREAM,
	RTMP_EVENT_DELETESTREAM,
	RTMP_EVENT_RELEASESTREAM,
} RtRtmpEvent;

class IRtRtmpSessionSink
{
public:
	virtual void OnRtmpEvent(RtRtmpEvent inEvent, IRtRtmpSession* inSession) = 0;
// 	virtual void OnSend(IRtRtmpSession* inSession) = 0;
	virtual void OnClose(RtResult inReason, IRtRtmpSession* inSession) = 0;
	virtual void PullAvData(
		CRtString& outData, 
		BOOL& outIsAudio, 
		IRtRtmpSession* inSession) = 0;

protected:
	virtual ~IRtRtmpSessionSink() {}
};

#endif // __RT_RTMPMGR_API_H__

